Skip to content

Fix alternate lang tags #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 17, 2023
Merged

Fix alternate lang tags #3

merged 3 commits into from
Apr 17, 2023

Conversation

rickhanlonii
Copy link
Member

@rickhanlonii rickhanlonii commented Apr 14, 2023

Overview

The search index for the legacy site (in english) is kinda borked. For many pages, neither the legacy.reactjs.org/{slug} site is indexed, nor the reactjs.org/{slug} site. When this happens, Google is returning results for the first translated site with matches, and since many of the translated sites still have english content, a partially translated doc is indexed.

Screenshot 2023-04-14 at 3 23 04 PM

Why is this happening

According to the Google search console, when this happens it's because:

  • reactjs.org: Page is not indexed, redirects to legacy.reactjs.org 🛑
  • legacy.reactjs.org: Page is not indexed, alternate page with proper canonical tag {lang.reactjs.org} 🛑

Why doesn't this happen on all pages?

If you look deeper, you'll see that this doesn't happen on e.g. the Getting Started page:

Screenshot 2023-04-14 at 3 23 44 PM

Looking at the Google Search index, you see:

  • reactjs.org: Page is not indexed, redirects to legacy.reactjs.org 🛑
  • legacy.reactjs.org: Page is indexed ✅

I believe this is happening because all of the translated sites are fully translated to their corresponding language. So google doesn't trigger the "Alternate page with proper canonical tag" rule for those pages.

Fix

I've added legacy to all https://reactjs.org link, but we'll also need to update all of the translated docs repos to make the same change. Additionally, if we migrate the https://{lang}.reactjs.org sites to https://{lang}.legacy.reactjs.org we'll need to update every repo.

Before

<link rel="canonical" href="https://reactjs.org/"/>
<link rel="alternate" href="https://reactjs.org/" hreflang="x-default"/>
<link rel="alternate" hreflang="en" href="https://reactjs.org/"/>
<link rel="alternate" hreflang="ar" href="https://ar.reactjs.org/"/>
<link rel="alternate" hreflang="az" href="https://az.reactjs.org/"/>
<link rel="alternate" hreflang="es" href="https://es.reactjs.org/"/>
<link rel="alternate" hreflang="fr" href="https://fr.reactjs.org/"/>
<link rel="alternate" hreflang="hu" href="https://hu.reactjs.org/"/>
<link rel="alternate" hreflang="it" href="https://it.reactjs.org/"/>
<link rel="alternate" hreflang="ja" href="https://ja.reactjs.org/"/>
<link rel="alternate" hreflang="ko" href="https://ko.reactjs.org/"/>
<link rel="alternate" hreflang="mn" href="https://mn.reactjs.org/"/>
<link rel="alternate" hreflang="pl" href="https://pl.reactjs.org/"/>
<link rel="alternate" hreflang="pt-br" href="https://pt-br.reactjs.org/"/>
<link rel="alternate" hreflang="ru" href="https://ru.reactjs.org/"/>
<link rel="alternate" hreflang="tr" href="https://tr.reactjs.org/"/>
<link rel="alternate" hreflang="uk" href="https://uk.reactjs.org/"/>
<link rel="alternate" hreflang="zh-hans" href="https://zh-hans.reactjs.org/"/>
<link rel="alternate" hreflang="zh-hant" href="https://zh-hant.reactjs.org/"/>

After

<link rel="canonical" href="https://legacy.reactjs.org/">
<link rel="alternate" href="https://legacy.reactjs.org/" hreflang="x-default">
<link rel="alternate" hreflang="en" href="https://legacy.reactjs.org/">
<link rel="alternate" hreflang="ar" href="https://ar.reactjs.org/">
<link rel="alternate" hreflang="az" href="https://az.reactjs.org/">
<link rel="alternate" hreflang="es" href="https://es.reactjs.org/">
<link rel="alternate" hreflang="fr" href="https://fr.reactjs.org/">
<link rel="alternate" hreflang="hu" href="https://hu.reactjs.org/">
<link rel="alternate" hreflang="it" href="https://it.reactjs.org/">
<link rel="alternate" hreflang="ja" href="https://ja.reactjs.org/">
<link rel="alternate" hreflang="ko" href="https://ko.reactjs.org/">
<link rel="alternate" hreflang="mn" href="https://mn.reactjs.org/">
<link rel="alternate" hreflang="pl" href="https://pl.reactjs.org/">
<link rel="alternate" hreflang="pt-br" href="https://pt-br.reactjs.org/">
<link rel="alternate" hreflang="ru" href="https://ru.reactjs.org/">
<link rel="alternate" hreflang="tr" href="https://tr.reactjs.org/">
<link rel="alternate" hreflang="uk" href="https://uk.reactjs.org/">
<link rel="alternate" hreflang="zh-hans" href="https://zh-hans.reactjs.org/">
<link rel="alternate" hreflang="zh-hant" href="https://zh-hant.reactjs.org/">

Copy link
Member

@Daniel15 Daniel15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@ghost
Copy link

ghost commented Apr 14, 2023

What you see is React in the Persian letters 😄 رياكت

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants